using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Spire.Presentation.Drawing;

namespace Spire.Presentation.Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnRun_Click(object sender, EventArgs e)
        {
            //create PPT document
            Presentation presentation = new Presentation();

            //set background Image
            string ImageFile = @"..\..\..\..\..\..\Data\bg.png";
            RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
            presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

            //insert image to PPT
            string ImageFile2 = @"..\..\..\..\..\..\Data\pic.png";
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile2, new RectangleF(80, 100, 376, 197));
            presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

            //append new shape
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(20, 40, 600, 50));
            shape.Fill.FillType = FillFormatType.None;
            shape.ShapeStyle.LineColor.Color = Color.White;

            //add text to shape
            shape.TextFrame.Text = "The sample demonstrates how to insert a image into a slide.";
            TextRange textRange = shape.TextFrame.TextRange;

            //set the Font
            textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            textRange.Fill.SolidColor.Color = Color.Black;
            textRange.LatinFont = new TextFont("Arial Black");

            //save the document
            presentation.SaveToFile("InsertPicture.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("InsertPicture.pptx");
        }
    }
}